# -*- coding: utf-8 -*-
import scrapy


class BaiduSpider(scrapy.Spider):
    # 爬虫名,用于运行爬虫,scrapy crawl baidu
    name = 'baidu'
    # 允许抓取的域名
    allowed_domains = ['www.baidu.com']
    # 起始的URL地址
    start_urls = ['http://www.baidu.com/']

    def parse(self, response):
        # xpath():[<Selector xpath='/html/head/title/text()' data='百度一下，你就知道'>]
        # extract(): ['百度一下,你就知道']
        # extract_first(): '百度一下,你就知道'
        # get(): '百度一下,你就知道'
        r = response.xpath('/html/head/title/text()')
        r = r.get()

        print('*' * 50)
        print(r)








